package ${managerImpPackage};

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import ${entityPackage}.${className};
import ${commonPackage}.entity.Pagination;
import ${daoPackage}.${className}Dao;
import ${managerPackage}.${className}Manager;

 /**
 * 描述：</b>${codeName}持久化接口实现<br>
 * @author：系统生成
 * @version:v1.0
 */
@Repository("${lowerName}Manager")
public class ${className}ManagerImpl implements ${className}Manager {
	@SuppressWarnings("unused")
	private final static Logger logger= LoggerFactory.getLogger(${className}ManagerImpl.class);
	
	@Resource
	private ${className}Dao ${lowerName}Dao;
	
	 /* 
	 * (non-Javadoc)
	 * @see ${managerPackage}.${className}Manager#insert${className}(${entityPackage}.${className})
	 */
	@Transactional(rollbackFor={Exception.class})
	@Override
	public ${className} insert${className}(${className} ${lowerName}){
		${lowerName}Dao.insert(${lowerName});
		return ${lowerName};
	}
	
	<#if columnKeyParam !="">
     /* 
	 * (non-Javadoc)
	 * @see ${managerPackage}.${className}Manager#query${className}ByPrimaryKey(<#list columnKeyDatas as item><#if item_index==0>${item.dataType}<#else>,${item.dataType}</#if></#list>)
	 */
	@Override
	public ${className} query${className}ByPrimaryKey(${columnKeyParam}){
		return (${className}) ${lowerName}Dao.get(<#list columnKeyDatas as item><#if item_index==0>${item.domainPropertyName}<#else>,${item.domainPropertyName}</#if></#list>);
	}
	</#if>

	 /* 
	 * (non-Javadoc)
	 * @see ${managerPackage}.${className}Manager#update${className}ByPrimaryKey(${entityPackage}.${className})
	 */
	@Transactional(rollbackFor={Exception.class})
	@Override
	public void update${className}ByPrimaryKey(${className} ${lowerName}){
		int count = ${lowerName}Dao.update(${lowerName});
		if(count!=1 && ${lowerName}.getLastUpdateNo()!=null){
			throw new RuntimeException("更新${codeName}出现并发异常处理");
		}
	}

	/* 
	 * (non-Javadoc)
	 * @see ${managerPackage}.${className}Manager#update${className}ByPrimaryKey(${entityPackage}.${className})
	 */
	@Transactional(rollbackFor={Exception.class})
	@Override
	public Integer update${className}ByCondition(${className} ${lowerName}){
		return ${lowerName}Dao.update(${lowerName});
	}
	
	<#if columnKeyParam !="">
	/**
     * (non-Javadoc)
	 * @see ${managerPackage}.${className}Manager#delete${className}ByPrimaryKey(<#list columnKeyDatas as item><#if item_index==0>java.lang.${item.dataType}<#else>,java.lang.${item.dataType}</#if></#list>)
     */
    @Transactional(rollbackFor={Exception.class})
    @Override
	public void delete${className}ByPrimaryKey(${columnKeyParam}){
		${lowerName}Dao.delete(${columnKeyParamValue});
	}
	</#if>
	
	/**
	 * (non-Javadoc)
	 * @see ${managerPackage}.${className}Manager#query${className}ByPage(${entityPackage}.${className})
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Pagination<${className}> query${className}ByPage(${className} ${lowerName}){
		return (Pagination<${className}>) ${lowerName}Dao.getPagenationList(${lowerName});
	}
	
	/**
	 * (non-Javadoc)
	 * @see ${managerPackage}.${className}Manager#query${className}ListByCondition(${entityPackage}.${className})
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<${className}> query${className}ListByCondition(${className} ${lowerName}){
		return (List<${className}>) ${lowerName}Dao.getList(${lowerName});
	}
	
	/*user customize code start*/
${userCustomCode}
	/*user customize code end*/
}
